import { ref } from 'vue'
import { createStore } from 'vuex'
import getRandomNumber from '../utils/getRandom'
export default createStore({
  state: {
    list: ref([])
  },
  mutations: {
    getList(state, content) {
      state.list.value = content
      // console.log(state.list.value);
      const len: number = state.list.value.length;
      const res = [];
      const arr = getRandomNumber(len - 1, 6);
      for (let i = 0; i < arr.length; i++) {
        res.push({ title: state.list.value[arr[i]].title, id: state.list.value[arr[i]].id })
      }
      sessionStorage.setItem('random', JSON.stringify(res))
    }
  },
  actions: {

  },
  modules: {
  }
})
